#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"

REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"

TARGET_DATE="$(date --date='1 day ago' '+%Y%m%d')"
if [ -n "${1}" ]; then
  TARGET_DATE="${1}"
fi

# venv activate
source "${REPO_ROOT}/venv/bin/activate"
cd python

./pyrunner coin/support/proto_log/app/pta_runner.py \
  --trading_date=${TARGET_DATE}

deactivate
